package com.web.ShoppingDemo.action;


import java.io.ByteArrayInputStream;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.web.ShoppingDemo.model.User;

@Controller
@Scope("prototype")
public class UserAction extends BaseAction<User>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public String login(){
		//进行登录的判断
		model = userService.getLogin(model);
		if(model == null){
			session.put("error", "登录失败");
			return "ulogin";
		}else{
			//登录成功,返回到相应的页面
			session.put("user", model);
			//根据session是否有goURL确定页面的跳转
			if(session.get("goURL")==null){
				return "index";
			}else{
				return "goURL";
			}
		}
	}
	private String sname;
	
	public String getSname() {
		return sname;
	}


	public void setSname(String sname) {
		this.sname = sname;
	}

	/**
	 * 判断是否存在用户名
	 * @return
	 */
	public String checkName(){
		System.out.println("----check----");
		if(sname.equals("admin")){
			//查询的业务逻辑
			inputStream = new ByteArrayInputStream("false".getBytes());
		}else{
			inputStream = new ByteArrayInputStream("true".getBytes());
		}
		return "stream";
	}

}
